<template>
  <view>
    <view class="">
      <my-tabbar></my-tabbar>
    </view>
    <view class="">
      <my-plane @open="openhandel"></my-plane>
    </view>

    <view class="">
      <my-scroll></my-scroll>
    </view>

    <view class="" style="padding-bottom:15%;">
      <my-footers></my-footers>
    </view>


    <!-- 电话弹窗框示例 -->
    <view class="container" style="">

      <uni-popup ref="popup" type="popup" style="z-index: 999;position: absolute;">
        <view class="" style="background-color: white;text-align: center;">
          <view class="" style="font-size: 28rpx;border-bottom: 1rpx solid #f5f5f5;height: 80rpx;line-height: 80rpx;">
            联系电话
          </view>
          <view @click="callPhone"
            style="font-size: 30rpx;border-bottom: 10rpx solid #f5f5f5;height: 80rpx;line-height: 80rpx;">
            商家电话：<span>17386083291</span></view>
          <view @click="close" class="" style="font-size: 28rpx;height:80rpx; line-height: 80rpx;">取消</view>
        </view>
      </uni-popup>
    </view>



  </view>
</template>

<script>
  import Bus from '@/utils/EventBus.js'
  import {
    mapState,
    mapMutations
  } from 'vuex'

  export default {

    data() {
      return {
        message: false
      }
    },
    created() {
      this.islogin()

    },
    onLoad() {
      this.refreshChild()
    },
    methods: {
      ...mapMutations('m_user', ['updateUserInfo']),

      openhandel() {


        this.$refs.popup.open('bottom')
      },
      //刷新子页面
      refreshChild() {

        Bus.$emit('refresh', !this.message)
      },

      //判断是否已经获取登录信息
      islogin() {
        const token = uni.getStorageSync('token')

        if (!token) {
          uni.showModal({
            title: '温馨提示',
            content: '授权微信登录后才能点餐！',
            showCancel: false,
            success: function success(res) {
              if (res.confirm) {

                uni.navigateTo({
                  url: '/pages/login/login'
                });
              }
            }
          });
        } else {
          uni.navigateTo({
            url: '/pages/home/my-scroll'
          });
        }
      },
      //关闭电话弹窗
      close() {
        this.$refs.popup.close()
      },
      //拨打电话
      callPhone() {
        uni.makePhoneCall({
          phoneNumber: '17386083292', // 电话号码必须为字符串
          success: function() {

            console.log('拨号成功');
          },
          fail: function() {

            console.log('拨号失败');
          }
        });

      },



      //关闭口味弹窗








    }
  }
</script>

<style lang="scss">

</style>